package cn.edu.sdu.sduhour.mapper;

import cn.edu.sdu.sduhour.entity.Report;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ReportMapper {
    //查询某人的报告
    @Select("select * from report where openid=#{openid}")
    List<Report> findOne(Report report);

    //增加一条报告记录
    @Insert("INSERT INTO `report` (`openid`,`nickName`,`avatarUrl`,`city`,`time`,`number`,`attribute`) VALUES (#{openid},#{nickName},#{avatarUrl},#{city},0,0,#{attribute})")
    void addOne(Report report);

    //更新一条报告记录
    @Update("UPDATE `sduhour`.`report` SET ${changeName}=#{changeNum} WHERE openid=#{openid}")
    void changeOne(Report report);

    //删除一条报告记录（管理员）
    @Delete("DELETE FROM `report` WHERE `id` = #{id}")
    void delOne(Report report);
}
